package cate.common.table.activity.dailyrecharge;

import cate.common.table.EExcel;
import cate.common.table.ESheet;
import cate.common.table.activity.base.RechargeAddUpBaseRow;
import cate.common.table.activity.dailyrecharge.item.DailyRechargeItemRow;
import cate.common.table.activity.dailyrecharge.item.DailyRechargeItemSheet;
import easy.java.dev.note.NoteClass;

import java.util.HashMap;
import java.util.Map;

@NoteClass("每日充值Excel")
public class DailyRechargeExcel extends EExcel {

    public DailyRechargeItemSheet item = new DailyRechargeItemSheet();

    @Override
    public String getFileName() {
        return "每日充值.xlsx";
    }

    @Override
    public ESheet<?>[] getSheets() {
        return new ESheet[]{item};
    }

    /**
     * 获取累充条目配置
     *
     *  @param configId 配置ID
     * @param day 活动天数
     */
    public Map<Integer, RechargeAddUpBaseRow> getConfigs(int configId, int day) {
        Map<Integer, RechargeAddUpBaseRow> retMap = new HashMap<>();
        if (!item.configIdToMaxDay.containsKey(configId)) {
            return retMap;
        }
        int maxDay = item.configIdToMaxDay.get(configId);
        if (maxDay <= 0) {
            return retMap;
        }
        int realDay = (day - 1) % item.configIdToMaxDay.get(configId) + 1;
        for (DailyRechargeItemRow configRow : item.getList()) {
            if (configRow.configId == configId && configRow.dayIndex == realDay) {
                retMap.put(configRow.id, configRow);
            }
        }
        return retMap;
    }
}
